//
// Created by EmFi on 2023/5/12.
//

#ifndef DBMS_LOGUTIL_H
#define DBMS_LOGUTIL_H

#include <string>
#include "StringUtil.h"
#include "TimeUtil.h"

using namespace std;

class LogUtil {
public:
    static void debug(const string& db, const string& content) {
        cout << "[DEBUG] " << StringUtil::timeInfoToString(TimeUtil::now()) << "\tDB: " << db << "\t" << content << endl;
    }

    static void error(const string& db, const string& content) {
        cout << "[ERROR] " << StringUtil::timeInfoToString(TimeUtil::now()) << "\tDB: " << db << "\t" << content << endl;
    }

    static void operate(const string& db, OperationType op, const string& content) {
        cout << "[" << StringUtil::operationTypeToString(op) << "] " << StringUtil::timeInfoToString(TimeUtil::now()) << "\tDB: " << db << "\t" << content << endl;
    }

    static void query(const string& db, int select, int filter) {
        cout << "[QUERY] " << StringUtil::timeInfoToString(TimeUtil::now()) << "\tDB: " << db << "\t" << "Select " << select << " Object(s) And Filter " << filter << " Object(s)" << endl;
    }

    static void rollback(const string& db, int index) {
        cout << "[ROLLBACK] " << StringUtil::timeInfoToString(TimeUtil::now()) << "\tDB: " << db << "\t" << "To transaction index " << index << endl;
    }
};


#endif //DBMS_LOGUTIL_H
